import axiosInstance from "@/axios"
// import store from '@/pages/index/store'

/**
 * @desc 获取邮箱验证码
 * @param {Object} addAddress
 */
export function get_email_code(addAddress) {
	return axiosInstance({
		method: 'post',
		headers: {
			smskey: '855228c94ac52c829b26b7a7317b8d91e04cb1de'
		},
		url: '/Email/Email.php?s=emailRegister',
		data: {
			addAddress
		}
	})
}

/**
 * @desc 邮箱注册
 * @param {Object} params
 */
export function email_register(params) {
	return axiosInstance({
		method: 'post',
		url: '/User/User.php?s=emailRegister',
		data: params
	})
}

/**
 * @desc 登录
 * @param {Object} params
 */
export function login(params) {
	return axiosInstance({
		method: 'post',
		url: '/User/User.php?s=login',
		data: params
	})
}


/**
 * @desc 获取当前用户分类
 * @param {Object} params
 */
export function categoryList(params = {}) {
	// if(store.state.currentUserCategory.list.length){
	// 	return Promise.reject(store.state.currentUserCategory.list)
	// }
	return axiosInstance({
		method: 'get',
		url: '/Category/Category.php?s=getAll',
		params: params
	})
}

/**
 * @desc 创建分类
 * @param {Object} params
 */
export function categoryCreate(params) {
	return axiosInstance({
		method: 'post',
		url: '/Category/Category.php?s=addCategory',
		data: params
	})
}

/**
 * @desc 删除分类
 * @param {Object} params
 */
export function deleteCategory(classId) {
	return axiosInstance({
		method: 'post',
		url: '/Category/Category.php?s=deleteCategory',
		data: {
			classId
		}
	})
}


/**
 * @desc 修改分类
 * @param {Object} params
 */
export function amendCategory(params) {
	return axiosInstance({
		method: 'post',
		url: '/Category/Category.php?s=amendCategory',
		data: params
	})
}